package com.bdqn.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class StringChangeDateRak {
    public static Date stringChangeDate(String dateString){
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
        Date date = null;
        //2018.02.08 转换成了 20180208        //2018-02-08 转换成了 20180208        //2018/02/08 转换成了 20180208
        if(dateString.indexOf(".") > 0 || dateString.indexOf("-") > 0 || dateString.indexOf("/") > 0){
            dateString = dateString.replace(".","");
            dateString = dateString.replace("-","");
            dateString = dateString.replace("/","");
        }
        try {
            date = df.parse(dateString);
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return date;
    }

    public static String dateChangeString (Date date){
        String now = new SimpleDateFormat("yyyy年MM月dd日").format(date);
        //System.out.println(now);
        return now;
    }
}
